﻿<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Option Explicit %>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
<META NAME="copyright" CONTENT="Copyright 2009-2010 - Martechina Co.Ltd" />
<META NAME="Author" CONTENT="劢格机械(中国)  Www.Martechina.Com" />
<META NAME="Keywords" CONTENT="" />
<META NAME="Description" CONTENT="" />
<TITLE>编辑新闻</TITLE>
<link href="css.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../inc/Admin.js"></script>
</HEAD>
<!--#include file="../inc/Const.asp" -->
<!--#include file="../inc/ConnSiteData.asp" -->
<!--#include file="CheckAdmin.asp"-->
<%
'cookie 验证
'if Instr(request.cookies("Martech_com")("AdminPurview"),"|18,")=0 then 
'  response.write ("<font color='red')>你不具有该管理模块的操作权限，请返回！</font>")
'  response.end
'end if

'session 验证
if Instr(session("AdminPurview"),"|18,")=0 then 
  response.write ("<font color='red')>你不具有该管理模块的操作权限，请返回！</font>")
  response.end
end if
'========判断是否具有管理权限
%>
<BODY>
<% 
dim Result
Result=request.QueryString("Result")
dim ID,Name,ViewFlag,SortName,SortID,SortPath,Key,miaoshu
dim GroupID,GroupIdName,Exclusive,NoticeFlag,Source,Content,pic
ID=request.QueryString("ID")
call NewsEdit() 
%>
<table border="0" cellspacing="1" cellpadding="0" height="0" align="center" width="100%" >
  <tr>
  <td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#ffffff">

  <tr class=classtop>
    <td height="24" align="center" nowrap><a href="NewsEdit.asp?Result=Add" onClick='changeAdminFlag("添加产品信息")'>添加新闻信息</a><font color="#0000FF">&nbsp;|&nbsp;</font><a href="NewsList.asp" onClick='changeAdminFlag("产品列表")'>查看所有新闻信息</a></td>
  </tr>
</table>
<br>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#ffffff">
<script language="javascript">
// 参数说明
// s_Type : 文件类型，可用值为"image","flash","media","file"
// s_Link : 文件上传后，用于接收上传文件路径文件名的表单名
// s_Thumbnail : 文件上传后，用于接收上传图片时所产生的缩略图文件的路径文件名的表单名，当未生成缩略图时，返回空值，原图用s_Link参数接收，此参数专用于缩略图
function showUploadDialog(s_Type, s_Link, s_Thumbnail){
	//以下style=coolblue,值可以依据实际需要修改为您的样式名,通过此样式的后台设置来达到控制允许上传文件类型及文件大小
	var arr = showModalDialog("../martech_editor/dialog/i_upload.htm?style=light&type="+s_Type+"&link="+s_Link+"&thumbnail="+s_Thumbnail, window, "dialogWidth:0px;dialogHeight:0px;help:no;scroll:no;status:no");
}
</script>
  <form name="editForm" method="post" action="NewsEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>">
<tr>
 <td height="27" colspan="4" align="center" class="classtop"><strong>添加修改新闻</strong></td>
</tr>
      <tr class=classtd>
        <td   height="20" align="right">新闻名称：</td>
        <td   ><input name="Name" type="text" class="textfield" id="Name" style="WIDTH: 240;" value="<%=Name%>" maxlength="100">&nbsp;显示：<input name="ViewFlag" type="checkbox" style='HEIGHT: 13px;WIDTH: 13px;' value="1" checked <%if ViewFlag then response.write ("checked")%>>
&nbsp;*&nbsp;不少于3个字符</td>
      </tr>
      <tr class=classtd>
        <td height="20" align="right"  >关键字：</td>
        <td  ><input name="Key" type="text" class="textfield" id="Key" style="WIDTH: 240;" value="<%=Key%>" maxlength="100">
          &nbsp;发布：
&nbsp;&nbsp;6个词以内用<b>，</b>号隔开</td>
      </tr>
     <tr class=classtd>
        <td height="20" align="right"  >描　　述：</td>
        <td  ><textarea name="miaoshu" rows="3" class="textfield" id="miaoshu" style="WIDTH: 440;"><%=miaoshu%></textarea>&nbsp;发布：&nbsp;&nbsp;250个字符以内</td> 
      </tr>    
     <tr class=classtd>
        <td   height="20" align="right">所属类别：</td>
        <td  ><input name="SortName" type="text" class="textfield" id="SortName" value="<%=SortName%>" style="WIDTH: 240;background-color:#EBF2F9;" readonly>&nbsp;<a href="javaScript:OpenScript('SelectSort.asp?Result=News',500,500,'')"><img src="../Images/Select.gif" width="30" height="16" border="0" align="absmiddle"></a></td>
      </tr>
    <tr class=classtd>
        <td   height="20" align="right">类别数字：</td>
        <td  ><input name="SortID" type="text" class="textfield" id="SortID" style="WIDTH: 40;background-color:#EBF2F9;" value="<%=SortID%>" readonly><input name="SortPath" type="text" class="textfield" id="SortPath" style="WIDTH: 200;background-color:#EBF2F9;" value="<%=SortPath%>" readonly>&nbsp;*</td>
      </tr>
     <tr class=classtd>
        <td   height="20" align="right">新闻来源：</td>
        <td  ><input name="Source" type="text" class="textfield" style="WIDTH: 240;" value="<%=Source%>" maxlength="100"></td>
      </tr>
      <tr class=classtd>
        <td   height="20" align="right">标　　记：</td>
        <td  ><input name="NoticeFlag" type="checkbox" style="HEIGHT: 13px;WIDTH: 13px;" value="1" <%if NoticeFlag then response.write ("checked")%>>&nbsp;是否为图片新闻</td>
      </tr>
    <tr class=classtd>
        <td   height="25" align="right">图片地址：</td>
    
        <td  ><input name="pic" type="text" class="textfield" style="WIDTH: 240; height:25;" value="<%=pic%>" maxlength="100">&nbsp;<!--<iframe frameborder=0 marginWidth=5  marginHeight=5 width=260 height=25 scrolling=no src="upload.asp?action=pic"></iframe>--><input type=button class="button" style="WIDTH: 80;" value="上传图片" onClick="showUploadDialog('image', 'editForm.pic', '')"></td>
      </tr>
 
     <tr class=classtd>
        <td   height="20" align="right" valign="top">信息内容：<br>
      <td  > <textarea name="content" style="display:none"><%=Server.HtmlEncode(Content)%></textarea>
        <!--<iframe id="eWebEditor1" src="/martech_editor/ewebeditor.asp?id=content&style=s_light" frameborder="0" scrolling="no" width="650" height="350"></iframe>--><IFRAME ID="eWebEditor1" SRC="../martech_editor/ewebeditor.htm?id=content&style=light" FRAMEBORDER="0" SCROLLING="no" WIDTH="650" HEIGHT="350"></IFRAME></td>
      </tr>
     <tr class=classtd>
        <td   height="30" align="right">&nbsp;</td>
        <td   valign="bottom"><input name="submitSaveEdit" type="submit" class="button"  id="submitSaveEdit" value="保存" style="WIDTH: 80;" ></td>
      </tr>
  </form>
</table>
</td>
</tr>
</table>

</BODY>
</HTML>
<%
sub NewsEdit()
  dim Action,rsRepeat,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" then '保存编辑产品信息
    set rs = server.createobject("adodb.recordset")
    if len(trim(request.Form("Name")))<3 then
      response.write ("<script language=javascript> alert('新闻名称为必填项目！');history.back(-1);</script>")
      response.end
    end if
    if Result="Add" then '创建产品信息
	  sql="select * from Martech_News"
      rs.open sql,conn,1,3
      rs.addnew
      rs("Name")=trim(Request.Form("Name"))
	  if trim(Request.Form("Key"))=""then 
	  rs("Key")=left(trim(Request.Form("Name")),6)
	  else
	  rs("Key")=trim(Request.Form("Key"))
	  end if
	  if trim(Request.Form("Miaoshu"))="" then
	  rs("Miaoshu")=left(trim(Request.Form("Content")),255)
	  else
	  rs("Miaoshu")=trim(Request.Form("Miaoshu"))
	  end if
	  if Request.Form("ViewFlag")=1 then
        rs("ViewFlag")=Request.Form("ViewFlag")
	  else
        rs("ViewFlag")=0
	  end if
	  if Request.Form("SortID")="" and Request.Form("SortPath")="" then
        response.write ("<script language=javascript> alert('请选择所属分类！');history.back(-1);</script>")
        response.end
	  else
	    rs("SortID")=Request.Form("SortID")
		rs("SortPath")=Request.Form("SortPath")
	  end if
	  rs("Source")=trim(Request.Form("Source"))
	  if Request.Form("NoticeFlag")=1 then
        rs("NoticeFlag")=Request.Form("NoticeFlag")
	  else
        rs("NoticeFlag")=0
	  end if
   
	  rs("Content")=trim(Request.Form("Content"))
	  rs("pic")=trim(Request.Form("pic"))
	  rs("AddTime")=now()
	end if  
	if Result="Modify" then '修改产品信息
      sql="select * from Martech_News where ID="&ID
      rs.open sql,conn,1,3
      rs("Name")=trim(Request.Form("Name"))
	  rs("Key")=trim(Request.Form("Key"))
	  rs("Miaoshu")=trim(Request.Form("Miaoshu"))
	  if Request.Form("ViewFlag")=1 then
        rs("ViewFlag")=Request.Form("ViewFlag")
	  else
        rs("ViewFlag")=0
	  end if
	  if Request.Form("SortID")<>"" and Request.Form("SortPath")<>"" then
	    rs("SortID")=Request.Form("SortID")
		rs("SortPath")=Request.Form("SortPath")
	  else
        response.write ("<script language=javascript> alert('请选择所属分类！');history.back(-1);</script>")
        response.end
	  end if
	  rs("Source")=trim(Request.Form("Source"))
	  if Request.Form("NoticeFlag")=1 then
        rs("NoticeFlag")=Request.Form("NoticeFlag")
	  else
        rs("NoticeFlag")=0
	  end if
   
	  rs("Content")=rtrim(Request.Form("Content"))
	  rs("pic")=trim(Request.Form("pic"))
	end if
	rs.update
	rs.close
    set rs=nothing 
    response.write "<script language=javascript> alert('成功编辑新闻信息！');changeAdminFlag('新闻列表');location.replace('NewsList.asp');</script>"
  else '提取产品信息
	if Result="Modify" then
      set rs = server.createobject("adodb.recordset")
      sql="select * from Martech_News where ID="& ID
      rs.open sql,conn,1,1
      if rs.bof and rs.eof then
        response.write ("数据库读取记录出错！")
        response.end
      end if
	  Name=rs("Name")
	  Key=rs("Key")
	  Miaoshu=rs("Miaoshu")
	  ViewFlag=rs("ViewFlag")
	  SortName=SortText(rs("SortID"))
	  SortID=rs("SortID")
	  SortPath=rs("SortPath")
	  Source=rs("Source")
	  NoticeFlag=rs("NoticeFlag")
	
      Content=rs("Content")
	  pic=rs("pic")
	  rs.close
      set rs=nothing 
    end if
  end if
end sub
%>
<%
'生成所属类别--------------------------
Function SortText(ID)
  Dim rs,sql
  Set rs=server.CreateObject("adodb.recordset")
  sql="Select * From Martech_NewsSort where ID="&ID
  rs.open sql,conn,1,1
  SortText=rs("SortName")
  rs.close
  set rs=nothing
End Function
%>